Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

set-value

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

set-value

Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths.

  • 3.0.3
  • patch-3.0.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is set-value?

The set-value npm package is a utility for setting deeply nested values within an object using dot-path notation or by providing a path array. It is useful for updating values in a mutable way without directly accessing properties, especially when dealing with complex or deeply nested objects.

What are set-value's main functionalities?

Set nested values using dot-path

This feature allows you to set a value at a nested path within an object using a string dot-path notation.

const setValue = require('set-value');
const obj = {};
setValue(obj, 'a.b.c', 'value');
console.log(obj); //=> { a: { b: { c: 'value' } } }

Set nested values using array-path

This feature allows you to set a value at a nested path within an object using an array to describe the path.

const setValue = require('set-value');
const obj = {};
setValue(obj, ['a', 'b', 'c'], 'value');
console.log(obj); //=> { a: { b: { c: 'value' } } }

Set multiple values

This feature allows you to set multiple values at different paths within the same object.

const setValue = require('set-value');
const obj = {};
setValue(obj, 'a.b.c', 'value1');
setValue(obj, 'x.y.z', 'value2');
console.log(obj); //=> { a: { b: { c: 'value1' } }, x: { y: { z: 'value2' } } }

Other packages similar to set-value

Keywords

FAQs

Package last updated on 16 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc